home *** CD-ROM | disk | FTP | other *** search
- /*
- File: StringCompare.h
-
- Contains: Public interfaces for String Comparison and related operations
-
- Version: Technology: System 7.0 through System 8
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __STRINGCOMPARE__
- #define __STRINGCOMPARE__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #ifndef __TEXTCOMMON__
- #include <TextCommon.h>
- #endif
- #ifndef __SCRIPT__
- #include <Script.h>
- #endif
- #ifndef __TEXTOBJECTS__
- #include <TextObjects.h>
- #endif
- #ifndef __LOCALEOBJECTS__
- #include <LocaleObjects.h>
- #endif
- #ifndef __TEXTPARSER__
- #include <TextParser.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- /*
-
- Here are the current System 7 routine names and the translations to the older forms.
- Please use the newer forms in all new code and migrate the older names out of existing
- code as maintenance permits.
-
- NEW NAME OLD NAME OBSOLETE FORM (no handle)
-
- CompareString (Str255) IUCompPString (hp only) IUCompString (hp only)
- CompareText (ptr/len) IUMagPString IUMagString
- IdenticalString (Str255) IUEqualPString (hp only) IUEqualString (hp only)
- IdenticalText (ptr/len) IUMagIDPString IUMagIDString
- LanguageOrder IULangOrder
- ScriptOrder IUScriptOrder
- StringOrder (Str255) IUStringOrder (hp only)
- TextOrder (ptr/len) IUTextOrder
-
- RelString
- CmpString (a only)
- EqualString (hp only)
-
- ReplaceText
-
- */
- #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
-
- enum {
- /* Special language code values for Language Order*/
- systemCurLang = -2, /* current (itlbLang) lang for system script*/
- systemDefLang = -3, /* default (table) lang for system script*/
- currentCurLang = -4, /* current (itlbLang) lang for current script*/
- currentDefLang = -5, /* default lang for current script*/
- scriptCurLang = -6, /* current (itlbLang) lang for specified script*/
- scriptDefLang = -7 /* default language for a specified script*/
- };
-
- /* obsolete names*/
-
- enum {
- iuSystemCurLang = -2,
- iuSystemDefLang = -3,
- iuCurrentCurLang = -4,
- iuCurrentDefLang = -5,
- iuScriptCurLang = -6,
- iuScriptDefLang = -7
- };
-
- #endif
- /* FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE*/
- #if FOR_SYSTEM8_PREEMPTIVE
- typedef struct OpaqueCollationRef* CollationRef;
- typedef const UInt8 *ConstBytePtr;
- /* Collation object key names*/
- #define kCollateMasterKeyName "\pcollatemaster"
- /* Attribute names and values for CreateCollationRef*/
- #define kCollateUsageAttributeName "\pcollateusage"
- typedef FourCharCode CollateUsageAttributeValue;
-
- enum {
- kCollateUsageDictionary = 'dict',
- kCollateUsagePhoneDirectory = 'phon'
- };
-
- #define kCollateIdeoOrderAttributeName "\pcollateideoorder"
- typedef FourCharCode CollateIdeoOrderAttributeValue;
-
- enum {
- kCollateIdeoOrderRadicalStroke = 'rdst',
- kCollateIdeoOrderStrokeRadical = 'strd'
- };
-
- /* Override types and enums*/
- struct CollationSet {
- CharacterGroup charGroup;
- CharacterClass charClass;
- CharacterSubclassMask charSubclassMask;
- };
- typedef struct CollationSet CollationSet;
-
- typedef OptionBits CollateSetOptions;
-
- enum {
- kCollateMakeIgnorableBit = 0,
- kCollateSkipPreprocessingBit = 1,
- kCollateIgnoreAnnotationsBit = 2
- };
-
-
- enum {
- kCollateMakeIgnorableMask = 1 << kCollateMakeIgnorableBit,
- kCollateSkipPreprocessingMask = 1 << kCollateSkipPreprocessingBit,
- kCollateIgnoreAnnotationsMask = 1 << kCollateIgnoreAnnotationsBit
- };
-
- struct CollationSetOptionSpec {
- CharacterGroup charGroup;
- CharacterClass charClass;
- CharacterSubclassMask charSubclassMask;
- CollateSetOptions options;
- };
- typedef struct CollationSetOptionSpec CollationSetOptionSpec;
-
- typedef OptionBits CollateNumberOptions;
-
- enum {
- kCollateNumbersByValueBits = 0,
- kCollateAllowThousandsSepBits = 2,
- kCollateMoreThousandsSepBit = 4,
- kCollateAllowIdeoNumbersBit = 5
- };
-
-
- enum {
- kCollateNumbersByValueMask = 3 << kCollateNumbersByValueBits,
- kCollateAllowThousandsSepMask = 3 << kCollateAllowThousandsSepBits,
- kCollateMoreThousandsSepMask = 1 << kCollateMoreThousandsSepBit,
- kCollateAllowIdeoNumbersMask = 1 << kCollateAllowIdeoNumbersBit
- };
-
-
- enum {
- /* values for NumbersByValue subfield*/
- kCollateNumbersByValueUseLocale = 0,
- kCollateNumbersByValueNo = 1,
- kCollateNumbersByValueYes = 2, /* values for AllowThousands subfield*/
- kCollateAllowThousandsUseLocale = 0,
- kCollateAllowThousandsNo = 1,
- kCollateAllowThousandsYes = 2, /* values for MoreThousands subfield*/
- kCollateMoreThousandsUseLocale = 0,
- kCollateMoreThousandsSkipLocale = 1, /* values for AllowIdeoNumbers subfield*/
- kCollateAllowIdeoNumbersNo = 0,
- kCollateAllowIdeoNumbersYes = 1
- };
-
- typedef OptionBits CollateOptions;
-
- enum {
- kCollateStandardOptions = 0
- };
-
-
- enum {
- /* For determining equivalence, differences in encoding and between composed*/
- /* and decomposed characters are ignored (they are always significant for*/
- /* ordering, however). To change this use the following bits:*/
- kCollateEncodingSensitiveBit = 8,
- kCollateComposeSensitiveBit = 9, /* For determining equivalence, diacritics and case are normally significant.*/
- /* Use the following bits to change this.*/
- kCollateCaseInsensitiveBit = 10,
- kCollateDiacriticInsensitiveBit = 11, /* The following bits determine the ordering for the NoLocale functions only.*/
- kCollateNoLocaleOrderBits = 24
- };
-
-
- enum {
- kCollateEncodingSensitiveMask = 1L << kCollateEncodingSensitiveBit,
- kCollateComposeSensitiveMask = 1L << kCollateComposeSensitiveBit,
- kCollateCaseInsensitiveMask = 1L << kCollateCaseInsensitiveBit,
- kCollateDiacriticInsensitiveMask = 1L << kCollateDiacriticInsensitiveBit,
- kCollateNoLocaleOrderMask = 0x0000003F << kCollateNoLocaleOrderBits
- };
-
-
- enum {
- /* values for NoLocaleOrder subfield*/
- kCollateMacHFSUnicodeCodeOrder = 0 /* HFS order for Mac encodings, code order for Unicode*/
- };
-
- /* collation value for GetCollationKeyForTextString*/
- typedef UInt32 CollationValue;
- typedef SInt16 CollateResult;
- #endif
- /* FOR_SYSTEM8_PREEMPTIVE*/
- #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
- /*
- The following functions are old names, but are required for System 7 PowerPC builds
- becuase InterfaceLib exports these names, instead of the new ones.
- */
- extern pascal short IUMagPString(const void *aPtr, const void *bPtr, short aLen, short bLen, Handle itl2Handle)
- THREEWORDINLINE(0x3F3C, 0x001A, 0xA9ED);
-
- extern pascal short IUMagIDPString(const void *aPtr, const void *bPtr, short aLen, short bLen, Handle itl2Handle)
- THREEWORDINLINE(0x3F3C, 0x001C, 0xA9ED);
-
- extern pascal short IUTextOrder(const void *aPtr, const void *bPtr, short aLen, short bLen, ScriptCode aScript, ScriptCode bScript, LangCode aLang, LangCode bLang)
- THREEWORDINLINE(0x3F3C, 0x0022, 0xA9ED);
-
- extern pascal short IUScriptOrder(ScriptCode script1, ScriptCode script2)
- THREEWORDINLINE(0x3F3C, 0x001E, 0xA9ED);
-
- extern pascal short IULangOrder(LangCode language1, LangCode language2)
- THREEWORDINLINE(0x3F3C, 0x0020, 0xA9ED);
-
- extern pascal short IUCompPString(ConstStr255Param aStr, ConstStr255Param bStr, Handle itl2Handle);
-
- extern pascal short IUEqualPString(ConstStr255Param aStr, ConstStr255Param bStr, Handle itl2Handle);
-
- extern pascal short IUStringOrder(ConstStr255Param aStr, ConstStr255Param bStr, ScriptCode aScript, ScriptCode bScript, LangCode aLang, LangCode bLang);
-
- /*
- The following are new names which are not exported by System 7 InterfaceLib for PowerPC.
- For C the new names are mapped to the old names using #define.
- */
- #define CompareString(aStr, bStr, itl2Handle) \
- IUCompPString(aStr, bStr, itl2Handle)
- #define CompareText(aPtr, bPtr, aLen, bLen, itl2Handle) \
- IUMagPString(aPtr, bPtr, aLen, bLen, itl2Handle)
- #define IdenticalString(aStr, bStr, itl2Handle) \
- IUEqualPString(aStr, bStr, itl2Handle)
- #define IdenticalText(aPtr, bPtr, aLen, bLen, itl2Handle) \
- IUMagIDPString(aPtr, bPtr, aLen, bLen, itl2Handle)
- #define StringOrder(aStr, bStr, aScript, bScript, aLang, bLang) \
- IUStringOrder(aStr, bStr, aScript, bScript, aLang, bLang)
- #define TextOrder(aPtr, bPtr, aLen, bLen, aScript, bScript, aLang, bLang) \
- IUTextOrder(aPtr, bPtr, aLen, bLen, aScript, bScript, aLang, bLang)
- #define LanguageOrder(language1, language2) \
- IULangOrder(language1, language2)
- /*
- The following functions are new names that are exported by InterfaceLib
- and work on both 68k and System 7 PowerPC.
- */
- extern pascal short ScriptOrder(ScriptCode script1, ScriptCode script2)
- THREEWORDINLINE(0x3F3C, 0x001E, 0xA9ED);
-
- extern pascal short ReplaceText(Handle baseText, Handle substitutionText, Str15 key)
- FOURWORDINLINE(0x2F3C, 0x820C, 0xFFDC, 0xA8B5);
-
- #endif
- /* FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE*/
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- extern pascal short IUMagString(const void *aPtr, const void *bPtr, short aLen, short bLen)
- THREEWORDINLINE(0x3F3C, 0x000A, 0xA9ED);
-
- extern pascal short IUMagIDString(const void *aPtr, const void *bPtr, short aLen, short bLen)
- THREEWORDINLINE(0x3F3C, 0x000C, 0xA9ED);
-
- extern pascal short IUCompString(ConstStr255Param aStr, ConstStr255Param bStr);
-
- extern pascal short IUEqualString(ConstStr255Param aStr, ConstStr255Param bStr);
-
- #if CGLUESUPPORTED
- #if OLDROUTINENAMES
- extern short iucompstring(const char *aStr, const char *bStr);
-
- extern short iuequalstring(const char *aStr, const char *bStr);
-
- extern short iucomppstring(const char *aStr, const char *bStr, Handle intlHandle);
-
- extern short iuequalpstring(const char *aStr, const char *bStr, Handle intlHandle);
-
- extern short iustringorder(const char *aStr, const char *bStr, ScriptCode aScript, ScriptCode bScript, LangCode aLang, LangCode bLang);
-
- #endif
- #endif
- #endif
- /* FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED*/
- #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
- extern pascal short RelString(ConstStr255Param str1, ConstStr255Param str2, Boolean caseSensitive, Boolean diacSensitive);
-
- extern pascal Boolean EqualString(ConstStr255Param str1, ConstStr255Param str2, Boolean caseSensitive, Boolean diacSensitive);
-
- #if CGLUESUPPORTED
- extern short relstring(const char *str1, const char *str2, Boolean caseSensitive, Boolean diacSensitive);
-
- extern Boolean equalstring(const char *str1, const char *str2, Boolean caseSensitive, Boolean diacSensitive);
-
- #endif
- #endif
- /* FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE*/
- #if FOR_SYSTEM8_PREEMPTIVE
- extern OSStatus CreateCollationRef(LocaleObjectRef collMasterObject, LocaleRef locale, ItemCount countPairs, const NameValuePair *pairs, CollationRef *newCollationRef);
-
- extern OSStatus ChangeCollationRef(CollationRef collationRef, LocaleObjectRef collMasterObject, LocaleRef locale, ItemCount countPairs, const NameValuePair *pairs);
-
- extern OSStatus OverrideCollationSetOrder(CollationRef collationRef, ItemCount setCount, CollationSet setList[]);
-
- extern OSStatus OverrideCollationSetOptions(CollationRef collationRef, ItemCount specCount, CollationSetOptionSpec specList[]);
-
- extern OSStatus OverrideCollationNumberHandling(CollationRef collationRef, CollateNumberOptions numberOptions, ItemCount tokenCount, BasicToken tokenList[]);
-
- extern OSStatus DisposeCollationRef(CollationRef *collationRef);
-
- extern OSStatus GetCollationKeyForTextObject(CollationRef collationRef, ConstTextObject textObject, CollateOptions options, ItemCount maxCollationValues, ItemCount *actualCollationValues, CollationValue collationKey[]);
-
- extern OSStatus GetCollationKeyForTextString(CollationRef collationRef, ConstBytePtr textPtr, ByteCount textLength, TextEncoding textEncoding, CollateOptions options, ItemCount maxCollationValues, ItemCount *actualCollationValues, CollationValue collationKey[]);
-
- extern OSStatus CollateTextObjects(CollationRef collationRef, ConstTextObject textObject1, ConstTextObject textObject2, CollateOptions options, CollateResult *weakOrder, CollateResult *strictOrder);
-
- extern OSStatus CollateTextStrings(CollationRef collationRef, ConstBytePtr textPtr1, ByteCount textLength1, TextEncoding textEncoding1, ConstBytePtr textPtr2, ByteCount textLength2, TextEncoding textEncoding2, CollateOptions options, CollateResult *weakOrder, CollateResult *strictOrder);
-
- extern OSStatus EquivalentTextObjects(CollationRef collationRef, ConstTextObject textObject1, ConstTextObject textObject2, CollateOptions options, Boolean *equivalent);
-
- extern OSStatus EquivalentTextStrings(CollationRef collationRef, ConstBytePtr textPtr1, ByteCount textLength1, TextEncoding textEncoding1, ConstBytePtr textPtr2, ByteCount textLength2, TextEncoding textEncoding2, CollateOptions options, Boolean *equivalent);
-
- extern OSStatus FindInTextObject(CollationRef collationRef, ConstTextObject baseText, TextObjectIndex baseStartIndex, TextObjectIndex baseEndIndex, ConstTextObject pattern, TextObjectIndex patStartIndex, TextObjectIndex patEndIndex, CollateOptions options, TextObjectIndex *foundStartIndex, TextObjectIndex *foundEndIndex);
-
- extern OSStatus FindInTextString(CollationRef collationRef, ConstBytePtr baseText, ByteCount baseLength, TextEncoding baseEncoding, ByteOffset baseStartIndex, ByteOffset baseEndIndex, ConstBytePtr patText, ByteCount patLength, TextEncoding patEncoding, ByteOffset patStartIndex, ByteOffset patEndIndex, CollateOptions options, ByteOffset *foundStartIndex, ByteOffset *foundEndIndex);
-
- extern OSStatus SubstituteInTextObject(CollationRef collationRef, TextObject baseText, TextObjectIndex startIndex, TextObjectIndex endIndex, ConstTextObject substText, ConstTextObject pattern, CollateOptions options);
-
- /*
- Locale-insensitive utilities for text objects
- For internal, user-invisible behavior thay must remain invariant across different systems
- */
- extern OSStatus CollateTextObjectsNoLocale(ConstTextObject textObject1, ConstTextObject textObject2, CollateOptions options, CollateResult *weakOrder, CollateResult *strictOrder);
-
- extern OSStatus EquivalentTextObjectsNoLocale(ConstTextObject textObject1, ConstTextObject textObject2, CollateOptions options, Boolean *equivalent);
-
- extern OSStatus FindInTextObjectNoLocale(ConstTextObject baseText, TextObjectIndex baseStartIndex, TextObjectIndex baseEndIndex, ConstTextObject pattern, TextObjectIndex patStartIndex, TextObjectIndex patEndIndex, CollateOptions options, TextObjectIndex *foundStartIndex, TextObjectIndex *foundEndIndex);
-
- #endif
- /* FOR_SYSTEM8_PREEMPTIVE*/
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __STRINGCOMPARE__ */
-
-